package com.dhnsoft.education.controller.edu.front;

import com.dhnsoft.education.entity.article.EduArticle;
import com.dhnsoft.education.entity.edu.EduCourse;
import com.dhnsoft.education.entity.edu.EduTeacher;
import com.dhnsoft.education.entity.edu.vo.SubjectNestedVo;
import com.dhnsoft.education.service.article.EduArticleService;
import com.dhnsoft.education.service.edu.EduCourseService;
import com.dhnsoft.education.service.edu.EduTeacherService;
import com.dhnsoft.education.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description
 * @ClassName IndexFrontController
 * @Author dhn
 * @date 2022.03.11 21:18
 */
@RestController
@RequestMapping("/eduservice/indexFront")
//@CrossOrigin
public class IndexFrontController {
    @Autowired
    private EduCourseService courseService;

    @Autowired
    private EduTeacherService teacherService;

    @Autowired
    private EduArticleService articleService;

    //查询前8门热门课程，查询前4条名师
    @GetMapping("index")
    public R index(){
        //查询前8条热门课程
        List<EduCourse> eduCourseList = courseService.getHotCourse();
        //查询前4位名师
        List<EduTeacher> teacherList = teacherService.getTeacherBanner();
        //查询前4篇热门文章
        List<EduArticle> articleList = articleService.getHotArticle();
        //查询分类
        List<SubjectNestedVo> subjectList=courseService.getSubjectNestedList(null);
        return R.ok().data("courseList",eduCourseList).data("teacherList",teacherList).data("subjectList",subjectList).data("articleList",articleList);
    }
}
